import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/index'
import VueLazyload from 'vue-lazyload'
import './assets/style/iconfont.css'
import './assets/style/index.scss'
// import 'lib-flexible'

Vue.config.productionTip = false
Vue.use(VueLazyload, {
  preLoad: 1.3, //预加载的宽高比
  error: require('./assets/logo.png'), //图片加载失败时使用的图片源
  loading: require('./assets/loading.gif'), //图片加载的路径
  attempt: 1 //尝试加载次数
})


router.beforeEach((to, from, next) => {
  if (to.matched.length === 0) { //匹配前往的路由不存在
  	console.log("name: "+from.name+" path: "+from.path)
    from.name ? 
    	next({
	      name: from.name
	    }) : next('/404'); //判断此跳转路由的来源路由是否存在，存在的情况跳转到来源路由，否则跳转到404页面
  } else {
    next(); //如果匹配到正确跳转
  }
});


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
